<!DOCTYPE html>
<html>
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
  <meta content="yes" name="apple-mobile-web-app-capable">
  <meta content="black" name="apple-mobile-web-app-status-bar-style">
  <meta content="telephone=no" name="format-detection">
  <title>注册</title>
  <link href="${base}/templates/${config.theme}/mobile/static/css/layout.min.css" rel="stylesheet" type="text/css" />
  <link href="${base}/templates/${config.theme}/mobile/static/css/common.min.css" rel="stylesheet" type="text/css" />
  <script type="text/javascript" src="${base}/templates/${config.theme}/mobile/static/js/jquery.js"></script>
  <script type="text/javascript" src="${base}/templates/${config.theme}/mobile/static/js/jquery.cookie.js"></script>
  <script type="text/javascript" src="${base}/templates/${config.theme}/mobile/static/js/ajax.js"></script>
  <style>
    #switch-title {float:right;}
    #switch-title li {float:left;color:#000;border-bottom:2px solid #fff;font-size:16px;margin-right:10px;padding-bottom:5px;}
    #switch-title li.on-hit {color:green;border-bottom:2px solid green;}
  </style>
</head>
<body>
<header id="header" class="header clearfix">
  <div class="head_left fl"><a href="javascript:history.back(-1);"><span class="h_back"></span></a></div>
  <span class="headtit">绑定帐号</span>
  <div class="head_right fr"><a href="${base}/"><span class="h_home"></span></a></div>
</header>
<div>
  <div style="line-height:44px; height:44px; width:100%"></div>
  <div class="space15"></div>
  <div class="connerdiv" style="font-size:14px;color:#000000;text-align:left;padding:0px 8px;">绑定可享受红包积分等优惠
    <ul id="switch-title">
      <!--<li onclick="javascript:location.href='${base}/login';">登录</li>-->
      <!--<li onclick="javascript:location.href='${base}/register';" class="on-hit">注册</li>-->
    </ul>
    <div style="clear:both;"></div>
  </div>
  <div class="connerdiv" id="account-div">
    <form id="inputForm" action="${base}/register" method="post">
      <dl class="connerbox">
        <dd><span class="form_hd">手机号：</span><span class="form_td">
          <input type="hidden" id="weixinOpenId" name="weixinOpenId">
           <input type="hidden"  name="password" value="123456">
          <input name="username" id="username" type="text" placeholder="请输入手机号" value="" maxlength="50" class="text_input"></span></dd>
        <!--<dd> <span class="form_hd">验证码：</span><span style="margin-left: 45px;"><input style="width:120px;" type="tel" placeholder="请输入短信验证码" value="" id="code" class="text_input" name="code"><input type="button"  id="getCode" value="获取短信验证码" style="width:110px" onclick="getVerify()"></span></dd>-->
        <!--<dd><span class="form_hd">密码：</span><span class="form_td"><input name="password" id="password" type="password" value="" maxlength="50" placeholder="6－20位字母、数字结合" class="text_input"></span></dd>-->
        <!--<dd><span class="form_hd">确认密码：</span><span class="form_td ml80"><input name="rePassword" id="rePassword" type="password" value="" maxlength="50" placeholder="6－20位字母、数字结合" class="text_input"></span></dd>-->
        <dd><span class="form_hd">邀请码：</span><span class="form_td ml80"><input name="inviteCode" id="inviteCode" type="text" value="" maxlength="50" placeholder="代理邀请码" class="text_input"></span></dd>

      </dl>
      <dl id="tips" style="color:#da4f49; text-align:center; font-weight:bold;">
        [#if feedback??]
        ${feedback.content}
        [/#if]
      </dl>
      <div class="space15"></div>
      <input name="btnReg" type="submit" class="btn_red largerbtn longbtn" value="注册">
      <div class="space15"></div>
    </form>
  </div>
</div>
<script type="text/javascript">
  $(document).ready(function() {
    $("#inviteCode").val(localStorage.getItem('crtName'));
    $("#weixinOpenId").val(localStorage.getItem('unionid'));

    $('#inputForm').submit(function() {
      var username=$('#username').val();
      if(username.length==0){
        $('#inputForm #tips').html('请输入手机号！');
        return false;
      }
      if(username.length!=11){
        $('#inputForm #tips').html('请输入有效的手机号码！');
        return false;
      }
      var usernameReg = /^1[3|4|5|8|9|7][0-9]\d{4,8}$/;
      if(!usernameReg.test(username)){
        $('#inputForm #tips').html('请输入有效的手机号码！');
        return false;
      }
      // if($('#code').val()==''){
      //   $('#inputForm #tips').html('请输验证码！');
      //   return false;
      // }
      // if($('#password').val() == ''){
      //   $('#inputForm #tips').html('请输入密码！');
      //   return false;
      // }
      // if($('#rePassword').val() != $('#password').val()){
      //   $('#inputForm #tips').html('两次输入密码不一致，请重新输入！');
      //   return false;
      // }
    });
  });
  var c=60;
  var t;
  var issend = false;
  var returl = '';
  function timedCount(){
    $('#getCode').val(c+"秒再次获取");
    c=c-1;
    t=setTimeout("timedCount()",1000);
    if(c==0){
      stopCount();
    }
  }

  function stopCount(){
    clearTimeout(t);
    $('#getCode').val('获取短信验证码');
    issend = false;
    c=60;
  }

  function getVerify(){
    if($('#username').val() == ''){
      $('#inputForm #tips').html('请输入手机号！');
      return false;;
    }
    if(issend && c > 0){
      return;
    }
    //ajax
    $.ax("${base}/common/sms/send",
            {"mobile":$('#username').val(),"type":"registerMember"},'GET',null,'json',
            function(data){
              $("#code").val(data);
            },
            function(data){
            });
    issend = true;
    timedCount();
  }
</script>
</body>
</html>
